<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <link rel="stylesheet" href="../../libs/mui.min.css"/>
    <link rel="stylesheet" href="../../libs/app.css"/>
    <link rel="stylesheet" href="../../css/main.css"/>
    <link rel="stylesheet" href="../../css/assess.css"/>
</head>

<body>

<div class="head">
    <img class="mui-action-back" src="../../images/all-left.png" alt="">
    <p>选择该银行的业务</p>
</div>
<div class="content">
    <ul class="mui-table-view" id="business">
        <!--<li class="mui-table-view-cell">
            <a class="mui-navigate-right">Item 1</a>
        </li>-->
    </ul>
</div>

<script src="../../libs/mui.min.js"></script>
<script src="../../js/jquery-3.1.1.min.js"></script>
<script src="../../js/url.js"></script>
<script>
    //获取该银行的业务类型
    $.ajax({
        type: "get",
        url: ur + "rest/quickLoanController/quick-evaluate",
        async: true,
        headers: {
            'X-token': localStorage.token
        },
        dataType: 'json',
        data: {
            id: localStorage.fast_id
        },
        success: function (data) {
            if (data.meta.code == 'S002') {
                var list = data.data;
                if (list.length === 0) {
                    mui.toast('该银行暂无业务！')
                }
                for (var i = 0; i < list.length; i++) {
                    var item = '<li class="mui-table-view-cell business-item" key=' +
                        list[i].code + '><a class="mui-navigate-right">' +
                        list[i].name + '</a></li>';
                    $('#business').append(item);
                }
            } else {
                mui.toast(data.meta.message);
            }
        }
    });
    $('#business').on('tap', '.business-item', function () {
        var keys = $(this).attr('key');
        switch (keys) {
            case 'fcdy':
                href('pledge.html', 'pledge');
                break;
            case 'aj':
                href('home/pay-in.html', 'pay-in');
                break;
            case '2y':
                href('home/erya.html', 'erya');
                break;
            case 'qcdy':
                href('home/car.html', 'car');
                break;
            default:
                // 跳过个人信用消费贷款申请 直接评估
                // href('personal.html', 'personal');
                localStorage.loanCode = keys;
                pinggu();
        }
    });

    function pinggu() {
        console.log('localStorage.loanCode', localStorage.loanCode);
        $.ajax({
            url: ur + 'rest/loanController/getEvaluate',
            type: "get",
            dataType: 'json',
            headers: {
                "X-Token": localStorage.token
            },
            data: {
                loanCode: localStorage.loanCode,
                succ: true
            },
            success: function (data) {
                if (data.meta.code === 'S002') {
                    if (data.data.total > 0) {
                        href('select-assess.html', 'select-assess')
                    } else { //无评估时
                        mui.toast('请您先进行该项评估！')
                        localStorage.isAssess = localStorage.loanCode //是否评估页过去
                        switch (localStorage.loanCode) {
                            case 'rsbd':
                                href('one-life.html', 'one-life');
                                break;
                            case 'fdyg':
                                href('one-housing.html', 'one-housing');
                                break;
                            case 'ylzy':
                                href('one-professional.html', 'one-professional');
                                break;
                            case 'gsjx':
                                href('one-corporate.html', 'one-corporate');
                                break;
                            case 'fcdy':
                                href('two-house.html', 'two-house');
                                break;
                            case 'qcdy':
                                href('two-car.html', 'two-car');
                                break;
                                /*case 'aj':
                                 href('four-aj.html', 'four-aj');
                                 break;*/
                            case '2y':
                                href('three-2y.html', 'three-2');
                                break;
                        }
                    }
                } else {
                    //				mui.toast(data.meta.message);
                }
            }
        })
    }
</script>
</body>

</html>